
%% --------------------- Figure 2 -----------------------------------------
% To plot zero flows by country pairs
close all; clear; clc;

D = importdata('ZERO.txt');

Z0 = D.data(:,1);
ZZ = D.data(:,2:end-2);
x = D.data(:,end-1);
y = D.data(:,end);
[m,n] = size(ZZ);
m = m^(0.5);
MAT = [num2cell([mean(ZZ);ZZ]);];
Z = cell2mat(MAT(2:end,:));

figure(2);
ii = 6; % ex: 6 leather
z = reshape(Z(:,ii),m,m);
pcolor(z); pbaspect([1 1 1]);
xlabel('Exporter ranked by GDP');ylabel('Importer ranked by GDP');
set(gca,'XAxisLocation','top','Ydir','reverse'); 


%% --------------------- Figure 4 -----------------------------------------
% To plot zero flow fitness

clear; clc;

D = importdata('ZERO_fit.txt');

Z = D.data(:,1);
Z1 = D.data(:,2);
x = D.data(:,end-1);
y = D.data(:,end);
[m,n] = size(Z);
m = m^(0.5);

figure(4);
z = reshape(Z,m,m);
pcolor(z); pbaspect([1 1 1]);
xlabel('Exporter ranked by GDP');ylabel('Importer ranked by GDP');
set(gca,'XAxisLocation','top','Ydir','reverse'); colormap(jet(4));
